package com.sh.data.engine.application.model.request.integration;

import com.sh.data.engine.common.annotation.crypto.EncryptField;
import com.sh.data.engine.common.enumDefinition.DSType;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.Pattern;
import lombok.Data;
import org.hibernate.validator.constraints.Length;

import javax.validation.constraints.Max;
import javax.validation.constraints.Min;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;

@Data
public class DataSourceGeneralConnectionRequest {

    @Schema(
            description = "数据源名称",
            requiredMode = Schema.RequiredMode.REQUIRED,
            minLength = 2,
            maxLength = 32,
            pattern = "[a-zA-Z0-9_\\u4e00-\\u9fa5]+")
//    @NotBlank(message = "数据源名称不能为空")
    @Length(min = 2, max = 32, message = "数据源名称长度在2-32个字符")
    @Pattern(regexp = "[a-zA-Z0-9_\\u4e00-\\u9fa5]+", message = "数据源名称支持中文、字母、数字和下划线")
    private String dsName;

    @Schema(description = "数据源类型", requiredMode = Schema.RequiredMode.REQUIRED)
    @NotNull(message = "数据源类型不能为空")
    private DSType dsType;

    @Schema(description = "描述", maxLength = 128)
    @Length(max = 128, message = "描述长度不能超过128个字符")
    private String dsDesc;

//    @Schema(description = "数据源配置", requiredMode = Schema.RequiredMode.REQUIRED)
////    @NotNull(message = "数据源配置不能为空")
//    private DataSourceCreateRequest.DSConfig dsConfig;

    /**
     * hdfs的用户
     */
    private String hdfsUser;

    @Schema(description = "hive-site.xml地址，通过获取上传hive-site文件获取的参数")
    private String hiveSiteAddress;

    @NotBlank(message = "服务器不能为空")
    @Schema(description = "服务器")
    private String server;

    @NotNull(message = "端口不能为空")
    @Min(value = 0, message = "端口不能小于0")
    @Max(value = 65535, message = "端口不能大于65535")
    @Schema(description = "端口")
    private Integer port;

    @Schema(description = "连接属性")
    private String connectionProperty;

    @Schema(description = "数据库")
    private String dbName;

    @Schema(description = "权限检验空间，默认admin")
    private String authDbName;

    @Schema(description = "主键")
    private Long id;

    @Schema(description = "jdbc连接", requiredMode = Schema.RequiredMode.REQUIRED)
    private String dsLink;

    @Schema(description = "用户名")
    private String username;

    @Schema(description = "密码")
    private String password;

    @Schema(description = "API Token")
    private String apiToken;

    @Schema(description = "组织名称")
    private String orgName;
}
